package com.rainbowelephant.fun.fitness;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.support.v4.app.NavUtils;

public class PresetWorkoutActivity extends Activity {
	
	EditText editReps;
	EditText editWeight;
	EditText editSets;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_preset_workout);
        editReps = (EditText)findViewById(R.id.editReps);
        editWeight = (EditText)findViewById(R.id.editWeight);
        editSets = (EditText)findViewById(R.id.editWeight);
		Spinner spin = (Spinner) findViewById(R.id.WorkoutType);
		String [] workouts = {"Bench Press", "Dumbbells" , "Leg Press", "Dead-Lift"};//,"Push-Ups", "Sit-Ups", "Crunches", "Lunges", "Pull-Ups", "Squats"};
		ArrayAdapter<String> adapt = new ArrayAdapter<String>(this,R.layout.list_item, workouts);
		adapt.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spin.setAdapter(adapt);	
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_preset_workout, menu);
        return true;
    }

    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                NavUtils.navigateUpFromSameTask(this);
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    
    public void begin (View view){
    	String reps = editReps.getText().toString();
    	String weight = editWeight.getText().toString();
    	String sets = editSets.getText().toString();
    	Spinner spin = (Spinner)findViewById(R.id.WorkoutType);
    	String type = spin.getSelectedItem().toString();
    	Intent intent = new Intent(this, ChecklistActivity.class);
    	intent.putExtra("workoutType", type);
    	intent.putExtra("repNum", reps);
    	intent.putExtra("weightNum", weight);
    	intent.putExtra("setNum", sets);
    	startActivity(intent);
    }
}
